# coding=utf-8
import urllib.request


class htmlDownloader(object):

    def download(self, url):
        user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
        headers = {'User-Agent': user_agent}

        if url is None:
            return None
        response = urllib.request.urlopen(url)

        if response.getcode() != 200:
            return None
        #print(response.read().decode('utf-8'))#需要进行类型转换才能正常显示在python中
        #print(type(response.read().decode('utf-8')))#返回解码后的类型，此时为str类型
        #content = response.read().decode('utf-8')
        return response.read()
